import { TypeOrmModule } from '@nestjs/typeorm'

var requireContext = require('require-context')
const files = requireContext(__dirname, false, /entity.js$/)
const entityArr = files.keys().reduce((prev, cur) => {
  // 去掉BaseEntity
  if(cur.includes('base')) return prev
  Object.keys(files(cur)).forEach(key => {
    prev.push(files(cur)[key])
  })
  return prev
}, [])


export const models = TypeOrmModule.forFeature(entityArr)

// export const models = TypeOrmModule.forFeature([
//   UserEntity,
//   ArticleEntity,
//   ProvinceEntity,
//   ProductEntity,
//   categoryProduct,
//   CategoryEntity,
//   CategoryValueEntity,
//   ProductSkuEntity,
//   userProductSkuEntity,
//   UserAddressEntity
// ])
